<?php

namespace common\models\kingdee;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\kingdee\OrgPosition;

/**
 * OrgPositionSearch represents the model behind the search form about `common\models\kingdee\OrgPosition`.
 */
class OrgPositionSearch extends OrgPosition
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['FID', 'FNAME_L1', 'FNAME_L2', 'FNAME_L3', 'FNUMBER', 'FADMINORGUNITID', 'FJOBID', 'FEFFECTDATE', 'FVALIDATE', 'FDESCRIPTION_L1', 'FDESCRIPTION_L2', 'FDESCRIPTION_L3', 'FSIMPLENAME', 'FCREATORID', 'FCREATETIME', 'FLASTUPDATEUSERID', 'FLASTUPDATETIME', 'FHRORGUNITID', 'FCONTROLUNITID', 'FPOSITIONTYPEID', 'FPUBPROPERLDAP', 'FZDY1', 'FZDY2', 'FZDY3', 'FZDY4', 'FZDY5', 'FZDY6', 'FZDY11', 'FZDY12', 'FZDY13', 'FZDY14', 'FZDY15', 'FJOBLEVELID', 'FHISTORYRELATEID', 'FDOMAINID', 'FEFFDT', 'FLEFFDT', 'FPURPOSE', 'FLOWJOBGRADEID', 'FHIGHJOBGRADEID', 'FPARENTID', 'FPRODUCTLINEID', 'FPOSPLANCOUNT'], 'safe'],
            [['FINDEX', 'FDELETEDSTATUS', 'FISRESPPOSITION', 'FFLUCHECKTIME', 'FZDY7', 'FZDY8', 'FZDY9', 'FSORTCODE', 'FISCREATEBYJOB', 'FPOSITIONPLANCOUNT'], 'integer'],
            [['FZDY10'], 'number'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = OrgPosition::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'FINDEX' => $this->FINDEX,
            'FEFFECTDATE' => $this->FEFFECTDATE,
            'FVALIDATE' => $this->FVALIDATE,
            'FCREATETIME' => $this->FCREATETIME,
            'FLASTUPDATETIME' => $this->FLASTUPDATETIME,
            'FDELETEDSTATUS' => $this->FDELETEDSTATUS,
            'FISRESPPOSITION' => $this->FISRESPPOSITION,
            'FFLUCHECKTIME' => $this->FFLUCHECKTIME,
            'FZDY4' => $this->FZDY4,
            'FZDY5' => $this->FZDY5,
            'FZDY6' => $this->FZDY6,
            'FZDY7' => $this->FZDY7,
            'FZDY8' => $this->FZDY8,
            'FZDY9' => $this->FZDY9,
            'FZDY10' => $this->FZDY10,
            'FSORTCODE' => $this->FSORTCODE,
            'FISCREATEBYJOB' => $this->FISCREATEBYJOB,
            'FPOSITIONPLANCOUNT' => $this->FPOSITIONPLANCOUNT,
            'FEFFDT' => $this->FEFFDT,
            'FLEFFDT' => $this->FLEFFDT,
        ]);

        $query->andFilterWhere(['like', 'FID', $this->FID])
            ->andFilterWhere(['like', 'FNAME_L1', $this->FNAME_L1])
            ->andFilterWhere(['like', 'FNAME_L2', $this->FNAME_L2])
            ->andFilterWhere(['like', 'FNAME_L3', $this->FNAME_L3])
            ->andFilterWhere(['like', 'FNUMBER', $this->FNUMBER])
            ->andFilterWhere(['like', 'FADMINORGUNITID', $this->FADMINORGUNITID])
            ->andFilterWhere(['like', 'FJOBID', $this->FJOBID])
            ->andFilterWhere(['like', 'FDESCRIPTION_L1', $this->FDESCRIPTION_L1])
            ->andFilterWhere(['like', 'FDESCRIPTION_L2', $this->FDESCRIPTION_L2])
            ->andFilterWhere(['like', 'FDESCRIPTION_L3', $this->FDESCRIPTION_L3])
            ->andFilterWhere(['like', 'FSIMPLENAME', $this->FSIMPLENAME])
            ->andFilterWhere(['like', 'FCREATORID', $this->FCREATORID])
            ->andFilterWhere(['like', 'FLASTUPDATEUSERID', $this->FLASTUPDATEUSERID])
            ->andFilterWhere(['like', 'FHRORGUNITID', $this->FHRORGUNITID])
            ->andFilterWhere(['like', 'FCONTROLUNITID', $this->FCONTROLUNITID])
            ->andFilterWhere(['like', 'FPOSITIONTYPEID', $this->FPOSITIONTYPEID])
            ->andFilterWhere(['like', 'FPUBPROPERLDAP', $this->FPUBPROPERLDAP])
            ->andFilterWhere(['like', 'FZDY1', $this->FZDY1])
            ->andFilterWhere(['like', 'FZDY2', $this->FZDY2])
            ->andFilterWhere(['like', 'FZDY3', $this->FZDY3])
            ->andFilterWhere(['like', 'FZDY11', $this->FZDY11])
            ->andFilterWhere(['like', 'FZDY12', $this->FZDY12])
            ->andFilterWhere(['like', 'FZDY13', $this->FZDY13])
            ->andFilterWhere(['like', 'FZDY14', $this->FZDY14])
            ->andFilterWhere(['like', 'FZDY15', $this->FZDY15])
            ->andFilterWhere(['like', 'FJOBLEVELID', $this->FJOBLEVELID])
            ->andFilterWhere(['like', 'FHISTORYRELATEID', $this->FHISTORYRELATEID])
            ->andFilterWhere(['like', 'FDOMAINID', $this->FDOMAINID])
            ->andFilterWhere(['like', 'FPURPOSE', $this->FPURPOSE])
            ->andFilterWhere(['like', 'FLOWJOBGRADEID', $this->FLOWJOBGRADEID])
            ->andFilterWhere(['like', 'FHIGHJOBGRADEID', $this->FHIGHJOBGRADEID])
            ->andFilterWhere(['like', 'FPARENTID', $this->FPARENTID])
            ->andFilterWhere(['like', 'FPRODUCTLINEID', $this->FPRODUCTLINEID])
            ->andFilterWhere(['like', 'FPOSPLANCOUNT', $this->FPOSPLANCOUNT]);

        return $dataProvider;
    }
}
